package com.ruoyi.system.translate.service.impl;

import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.common.translate.constant.Translate;
import com.ruoyi.common.translate.NameProvider;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 部门名称映射
 */
@Service
public class DeptNameProvider extends NameProvider<SysDept> {

    @Resource
    private SysDeptMapper deptMapper;


    @Override
    public String getType() {
        return Translate.Type.DEPT;
    }

    @Override
    public SysDept findEntity(String key) {
        Long id = changeIdType(key);
        return deptMapper.selectDeptById(id);
    }

    @Override
    public List<SysDept> findEntityList(List<String> keys) {
        //TODO 批量查询
        ArrayList<SysDept> ret = new ArrayList<>();
        for (String key : keys) {
            Long id = changeIdType(key);
            SysDept data = deptMapper.selectDeptById(id);
            ret.add(data);
        }
        return ret;
    }

    @Override
    public Map<String, String> mapName(SysDept obj) {
        HashMap<String, String> ret = new HashMap<>();
        ret.put(baseKey + obj.getDeptId(), obj.getDeptName());
        return ret;
    }

}